#include "stm32f10x.h"                  // Device header
#include "uart.h"
#include "includes.h"
#include "task.h"
#include "LED.h"
#include "delay.h"

#define APP_Task_STK_SIZE 64

OS_TCB APP_TCB;
void APP_Task(void* p_arg);
CPU_STK  APP_Task_STK[APP_Task_STK_SIZE];

int main()
{
    OS_ERR err;
    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
    Uart3_init();
    delay_init();
    OSTaskCreate(
        (OS_TCB*)&APP_TCB,
        (CPU_CHAR*)"APP_Task",
        (OS_TASK_PTR)APP_Task,
        (void*)0,
        (OS_PRIO) 5,
        (CPU_STK*)APP_Task_STK[0],
        (CPU_STK_SIZE)  APP_Task_STK_SIZE / 10,
        (CPU_STK_SIZE)  	APP_Task_STK_SIZE,
        (OS_MSG_QTY) 0,
        (OS_TICK)   0,
        (void*)0,
        (OS_OPT)  OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR,
        (OS_ERR*)&err);
    printf("err = %d \r\n", err);
    OSStart((OS_ERR*)&err);
    while(1);
}


void APP_Task(void* p_arg)
{
    uint8_t count = 0;

    OS_ERR err;
    while(1)
    {
        count++;
        printf("task run %d times \r\n", count);
        OSTimeDlyHMSM(0, 0, 1, 0, OS_OPT_TIME_DLY, (OS_ERR*)&err);
    }
}

 